package com.ruoyi.common.entity;

/**
 * 交易状态枚举
 */
public enum TransStatusEnum {
    S("成功"),
    W("等待支付"),
    C("退款撤销"),
    R("失败"),
    N("状态未明");

    private final String description;

    TransStatusEnum(String description) {
        this.description = description;
    }

    public String getDescription() {
        return description;
    }

    @Override
    public String toString() {
        return this.name() + "(" + this.description + ")";
    }

    // 根据代码获取枚举值
    public static TransStatusEnum fromCode(String code) {
        for (TransStatusEnum status : TransStatusEnum.values()) {
            if (status.name().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Invalid TransStatusEnum code: " + code);
    }
}
